import type { AxiosResponse } from "axios"
import type { BaseViewResponseData, SearchTableResponseData, TableRequestData } from "./type"
import { request } from "@/http/axios"

export function getWeaponMounted(id: string) {
  return request({
    url: `/casia/scenario/entity/mount/getMountInfoList`,
    method: "get",
    params: {
      emoId: id
    }
  })
}

/**
 * 获取sim文件内容
 * @param param
 * @returns
 */
export function getSimContent(id: string) {
  return request({
    url: `/casia/scenario/sim/getSimContent/${id}`,
    method: "get"
  })
}

/**
 * 更新sim文件内容
 * @param param
 * @returns
 */
export function updateSimContent(data: any) {
  return request({
    url: `/casia/scenario/sim/updateSimFile`,
    method: "post",
    data
  })
}

/**
 * 控制对象名称重复
 */
export function isRepeatControlName(data: any) {
  return request<ApiResponseData<boolean>>({
    url: `/casia/scenario/controlObj/getRepeatNameCount`,
    method: "post",
    data
  })
}

/**
 * 根据id查询描述参数
 */
export function getEntityDetailInfo(id: string) {
  return request<ApiResponseData<any>>({
    method: "get",
    url: `/casia/model/entity/getEntityDetailInfo/${id}`
  })
}

/**
 * 根据id查询扩展参数
 */
export function getEntityDetail(id: string) {
  return request<ApiResponseData<any>>({
    method: "get",
    url: `/casia/scenario/entity/getEntityTempDetail/${id}`
  })
}

/**
 * 更新实例对象坐标
 */
export function updateEntityPosition(data: { id: string, position: any }) {
  return request<ApiResponseData<any>>({
    method: "post",
    url: `/casia/scenario/entity/updateEntityPosition`,
    data
  })
}

/**
 * 更新控制对象顶点
 */
export function updateControlObjPath(data: { id: string, path: string, param?: string }) {
  return request<ApiResponseData<any>>({
    method: "post",
    url: `/casia/scenario/controlObj/updateControlObjPath`,
    data
  })
}

/**
 * 删除控制对象实例
 */
export function deleteControlInstance(id: string) {
  return request<ApiResponseData<any>>({
    method: "delete",
    url: `/casia/scenario/controlObj/deleteControlObj/${id}`
  })
}

/**
 * 保存控制对象数据
 */
export function saveControlInstance(data: any) {
  return request<ApiResponseData<any>>({
    method: "post",
    url: `/casia/scenario/controlObj/createControlObj`,
    data
  })
}

/**
 * 保存控制对象数据
 */
export function updateControlName(data: any) {
  return request<ApiResponseData<any>>({
    method: "post",
    url: `/casia/scenario/controlObj/updateControlObjName`,
    data
  })
}

/**
 * 根据id查询控制对象实例
 */
export function getControlInstanceById(id: string) {
  return request <ApiResponseData<any>>({
    method: "get",
    url: `/casia/scenario/controlObj/getControlObj/${id}`
  })
}

/**
 * 根据想定id查询已选控制对象
 */
export function getSelectedInstanceByScnId(scnId: string) {
  return request<ApiResponseData<any>>({
    method: "get",
    url: `/casia/scenario/controlObj/getControlObjByScnId/${scnId}`
  })
}

/**
 * 更新环境信息
 */
export function updateEnv(data: any) {
  return request<ApiResponseData<any>>({
    method: "post",
    url: `/casia/scenario/environment/updateEnvironment`,
    data
  })
}

/**
 * 创建环境信息
 */
export function createEnv(data: any) {
  return request<ApiResponseData<any>>({
    method: "post",
    url: `/casia/scenario/environment/createEnvironment`,
    data
  })
}

/**
 * 查询环境详细信息
 */
export function getEnvDetail(id: string) {
  return request<ApiResponseData<any>>({
    method: "get",
    url: `/casia/scenario/environment/getEnvironmentByScnId/${id}`
  })
}

/**
 * 删除环境信息
 */
export function deleteEnv(id: string) {
  return request<ApiResponseData<any>>({
    method: "delete",
    url: `/casia/scenario/environment/deleteEnvironment/${id}`
  })
}

/**
 * 删除实体实例
 */
export function deleteEntityInstance(id: string) {
  return request<ApiResponseData<any>>({
    method: "delete",
    url: `/casia/scenario/entity/deleteEntity/${id}`
  })
}

/**
 * 更新实体实例
 */
export function updateEntityInstance(data: any) {
  return request<ApiResponseData<any>>({
    method: "post",
    url: `/casia/scenario/entity/updateEntity`,
    data
  })
}

/**
 * 根据id查询实体实例
 */
export function getEntityInstanceById(id: string) {
  return request<ApiResponseData<any>>({
    method: "get",
    url: `/casia/scenario/entity/getEntity/${id}`
  })
}

/**
 * 保存实体实例
 */
export function saveEntityInstance(data: any) {
  return request<ApiResponseData<any>>({
    method: "post",
    url: `/casia/scenario/entity/saveEntity`,
    data
  })
}

/**
 * 阵营名称、编码查重
 */
export function isRepeatCampLabelValue(params: {
  scnId?: string | null
  id?: string
  label?: string
  value?: string
}) {
  return request<ApiResponseData<boolean>>({
    method: "get",
    url: `/casia/scenario/camp/isRepeatLabelValue`,
    params
  })
}

/**
 * 根据id获取阵营信息
 */
export function getCamp(campId: string) {
  return request<ApiResponseData<any>>({
    method: "get",
    url: `/casia/scenario/camp/getCamp/${campId}`
  })
}

/**
 * 更新阵营
 */
export function updateCamp(data: any) {
  return request<ApiResponseData<any>>({
    method: "post",
    url: `/casia/scenario/camp/updateCamp`,
    data
  })
}

/**
 * 保存阵营
 */
export function saveCamp(data: any) {
  return request<ApiResponseData<any>>({
    method: "post",
    url: `/casia/scenario/camp/createCamp`,
    data
  })
}

/**
 * 根据想定id查询已选实体列表
 */
export function getSelectedEntityObjectsByScn(scnId: string) {
  return request<ApiResponseData<any>>({
    method: "get",
    url: `/casia/scenario/entity/getScnEntity`,
    params: {
      scnId
    }
  })
}

/**
 * 根据阵营id查询已选实体列表
 */
export function getSelectedEntityObjectsByCamp(campId: string) {
  return request<ApiResponseData<any>>({
    method: "get",
    url: `/casia/scenario/entity/getCampEntity`,
    params: {
      campId
    }
  })
}

/**
 * 根据想定id查询阵营列表
 */
export function getCampList(scnId: string) {
  return request<ApiResponseData<any>>({
    method: "get",
    url: `/casia/scenario/camp/getScnCamp`,
    params: {
      scnId
    }
  })
}

/**
 * 删除阵营
 */
export function deleteCamp(id: string) {
  return request<ApiResponseData<any>>({
    method: "delete",
    url: `/casia/scenario/camp/delete/${id}`
  })
}

/**
 * 查询实体对象
 */
export function getEntityObjects() {
  return request<ApiResponseData<any>>({
    method: "get",
    url: `/casia/scenario/entity/getEntityTempList`
  })
}

/**
 * 另存为
 */
export function saveAsScenarioApi(param: any) {
  return request<ApiResponseData<any>>({
    url: `/casia/scenario/manage/saveAsScenario`,
    method: "post",
    data: param
  })
}

/**
 * 从资源库导入
 */
export function importScenarioByLibApi(param: any) {
  return request<ApiResponseData<any>>({
    url: `/casia/scenario/manage/importScenarioByLib`,
    method: "post",
    data: param
  })
}

/**
 * 发布
 */
export function publishApi(data: any) {
  return request<ApiResponseData<any>>({
    url: `/casia/scenario/manage/publish`,
    method: "post",
    data
  })
}

/**
 * 导出想定文件
 */
export function exportScnApi(id: string) {
  return request<AxiosResponse>({
    headers: {
      "Content-Type": "application/octet-stream"
    },
    responseType: "blob",
    url: `/casia/scenario/manage/export/${id}`,
    method: "get"
  })
}

/**
 * 上传想定
 */
export function importZipApi(data: FormData) {
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    method: "post",
    url: `/casia/scenario/manage/importZip`,
    data
  })
}

// 查询想定列表
export function searchScenarioListApi(param: TableRequestData) {
  return request<SearchTableResponseData>({
    url: `/casia/scenario/manage/searchScenario`,
    method: "post",
    data: param
  })
}

/**
 * 查询想定基本信息
 */
export function searchScenarioBasic(id: string) {
  return request<BaseViewResponseData>({
    url: `/casia/scenario/manage/getScenario/${id}`,
    method: "get"
  })
}

/**
 * 更新想定
 */
export function updateScenarioApi(param: any) {
  return request({
    url: `/casia/scenario/manage/updateScenario`,
    headers: {
      "Content-Type": "multipart/form-data"
    },
    method: "post",
    data: param
  })
}

/**
 * 新增想定
 */
export function addScenarioApi(param: any) {
  return request({
    url: `/casia/scenario/manage/createScenario`,
    headers: {
      "Content-Type": "multipart/form-data"
    },
    method: "post",
    data: param
  })
}

/**
 * 批量删除想定
 */
export function deleteMulScenario(ids: string[]) {
  return request({
    url: `/casia/scenario/manage/deleteMulScenario`,
    method: "delete",
    data: {
      ids
    }
  })
}

//根据想定id查询所有实体名称
export function getEntityNameListApi(scnId: string) {
  return request({
    url: `/casia/scenario/manage/getEntityNameList/${scnId}`,
    method: "get",
  })
}

